﻿<metro:Window x:Class="SkypeTranslater.Windows.MailWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:conv="clr-namespace:SkypeTranslater.Converters"
              xmlns:extended="http://schemas.xceed.com/wpf/xaml/toolkit"
              xmlns:metro="http://schemas.codeplex.com/elysium/theme"
              Title="Emails"
              Width="630"
              Height="300">
	<Grid>
		<Grid.Resources>
			<conv:TruncateConverter x:Key="Truncate" />
		</Grid.Resources>
		<Grid.RowDefinitions>
			<RowDefinition Height="27" />
			<RowDefinition />
			<RowDefinition Height="27" />
		</Grid.RowDefinitions>
		<ComboBox x:Name="cmbFolders"
		          Width="140"
		          Margin="1,1,1,1"
		          HorizontalAlignment="Left"
		          DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
		                                                               AncestorType=Window}}"
		          FontSize="11"
		          ItemsSource="{Binding Folders}"
		          SelectionChanged="cmbFolders_SelectionChanged" />
		<DataGrid x:Name="dataGridMails"
		          Grid.Row="1"
		          AutoGenerateColumns="False"
		          CanUserAddRows="False"
		          CanUserDeleteRows="False"
		          DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
		                                                               AncestorType=Window}}"
		          ItemsSource="{Binding MailItems}"
		          MouseDoubleClick="dataGridMails_MouseDoubleClick"
		          VirtualizingStackPanel.IsVirtualizing="True"
		          VirtualizingStackPanel.VirtualizationMode="Recycling">
			<DataGrid.Columns>
				<DataGridTextColumn Width="140"
				                    Binding="{Binding SenderName}"
				                    Header="Sender" />
				<DataGridTextColumn Width="180"
				                    Binding="{Binding Subject}"
				                    Header="Subject" />
				<DataGridTemplateColumn Width="80" Header="Date">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<DatePickerTextBox Foreground="Blue" Text="{Binding SentDate}" />
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridCheckBoxColumn Binding="{Binding HasAttachments, Mode=OneWay}" Header="Has attachment(s)" />
			</DataGrid.Columns>
			<DataGrid.RowDetailsTemplate>
				<DataTemplate>
					<TextBlock Height="50"
					           Text="{Binding Path=Body,
					                          Converter={StaticResource Truncate},
					                          ConverterParameter=80}"
					           TextWrapping="Wrap" />
				</DataTemplate>
			</DataGrid.RowDetailsTemplate>
			<DataGrid.Resources />
		</DataGrid>
		<extended:BusyIndicator x:Name="busyIndicator"
		                        Grid.Row="1"
		                        BusyContent="Loading email list"
		                        IsBusy="False" />
		<StatusBar Grid.Row="2">
			<TextBlock Width="80">
				<TextBlock.Text>
					<Binding Path="UnreadCount" StringFormat="Unread items count: {0}" />
				</TextBlock.Text>
			</TextBlock>
		</StatusBar>
	</Grid>

</metro:Window>
